﻿// -------------------------------------------------------------------------
//    @FileName         :    NFSnsDetailPart.cpp
//    @Author           :    gaoyi
//    @Date             :    2025-03-31
//    @Email			:    445267987@qq.com
//    @Module           :    NFSnsDetailPart
//
// -------------------------------------------------------------------------

#include "NFSnsDetailPart.h"

#include <NFSnsDetailPartModule.h>
#include <NFSnsRoleDetail.h>

NFSnsDetailPart::NFSnsDetailPart()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFSnsDetailPart::~NFSnsDetailPart()
{
}

int NFSnsDetailPart::Init(NFSnsRoleDetail* pMaster, uint32_t partType)
{
    CHECK_NULL(0, pMaster);
    m_pRoleDetail = pMaster;
    m_roleId = pMaster->GetRoleId();
    m_partType = partType;

    return 0;
}

int NFSnsDetailPart::UnInit()
{
    return 0;
}

int NFSnsDetailPart::CreateInit()
{
    m_roleId = 0;
    m_pRoleDetail = nullptr;
    m_partType = 0;
    return 0;
}


int NFSnsDetailPart::ResumeInit()
{
    return 0;
}

int NFSnsDetailPart::RegisterMessage()
{
    return 0;
}

int NFSnsDetailPart::OnHandleClientMessage(uint32_t msgId, NFDataPackage& packet)
{
    NFLogError(NF_LOG_DEFAULT, m_roleId, "client part package not handle:{}", packet.ToString());
    return 0;
}

int NFSnsDetailPart::OnHandleServerMessage(uint32_t msgId, NFDataPackage& packet)
{
    NFLogError(NF_LOG_DEFAULT, m_roleId, "server part package not handle:{}", packet.ToString());
    return 0;
}

int NFSnsDetailPart::RegisterClientMessage(uint32_t msgId, bool createCo)
{
    return FindModule<NFSnsDetailPartModule>()->RegisterClientServiceMessage(NF_ST_LOGIC_SERVER, msgId, m_partType, createCo);
}

int NFSnsDetailPart::RegisterServerMessage(uint32_t msgId, bool createCo)
{
    return FindModule<NFSnsDetailPartModule>()->RegisterServerServiceMessage(NF_ST_LOGIC_SERVER, msgId, m_partType, createCo);
}

NFSnsRoleDetail* NFSnsDetailPart::GetRoleDetail()
{
    return m_pRoleDetail.GetPoint();
}

const NFSnsRoleDetail* NFSnsDetailPart::GetRoleDetail() const
{
    return m_pRoleDetail.GetPoint();
}


